import axios from 'axios'
import {commonParams} from './config'

export function getTopList () {
  const url = '/api/getToplist'
  return axios({
    url,
    method: 'GET'
  }).then(resp => Promise.resolve(resp))
}

export function getMusicList (topId) {
  const url = '/api/getMusicList'
  const params = Object.assign({}, commonParams, {
    '-': 'getUCGI06813578806821385',
    g_tk: 5381,
    loginUin: 0,
    hostUin: 0,
    notice: 0,
    platform: 'yqq.json',
    needNewCode: 0,
    data: JSON.stringify({
      'detail': {
        'module': 'musicToplist.ToplistInfoServer',
        'method': 'GetDetail',
        'param': {'topId': topId, 'offset': 0, 'num': 50}},
      'comm': {'ct': 24, 'cv': 0}
    })
  })
  return axios.get(url, {
    params
  }).then(resp => Promise.resolve(resp.data))
}
